package cn.edu.ctbu.kcsj.controller;

import cn.edu.ctbu.kcsj.domain.Student;
import cn.edu.ctbu.kcsj.service.StudentService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class TeacherController {
    @Autowired
    StudentService studentService;
    @RequestMapping("/teacher/teacherinfo")
    public String list(HttpServletRequest httprequest,Model model){
        HttpSession session=httprequest.getSession();
        if (session.getAttribute("userid")==null){
            return "redirect:/login/logins";
        }
        List<Student>students=studentService.findAll();
        model.addAttribute("data",students);
        return "/teacher/teacherinfo";
    }
}